package com.cams.backend.controller;


import com.cams.backend.common.lang.Result;
import com.cams.backend.entity.QueryDate;
import com.cams.backend.entity.Record;
import com.cams.backend.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cams
 * @since 2022-05-15
 */
@RestController
@RequestMapping("/record")
public class RecordController {
    @Autowired
    RecordService recordService;

    /**
     * 上班打卡
     * 交互接口
     * @author chs
     */
    @PostMapping("/onduty")
    public Result onduty(@RequestBody Record record){
        return recordService.onDuty(record);
    }

    /**
     * 下班打卡
     * 交互接口
     * @author chs
     */
    @PostMapping("/offduty")
    public Result offduty(@RequestBody Record record){
        return recordService.offDuty(record);
    }

    /**
     * 打卡情况
     * 交互接口
     * @author
     */
    @GetMapping("/{uid}")
    public Result findByUid(@PathVariable("uid")int uid){
        return recordService.findByUid(uid);
    }

    /**
     * 根据时间查看打卡情况
     * 交互接口
     * @author
     */
    @PostMapping("/date")
    public Result findByRtime(@RequestBody QueryDate queryDate){
        return recordService.findByRtime(queryDate);
    }


    /**
     * 查看某员工加班情况
     * 交互接口
     * @author
     */
    @PostMapping("/uid")
    public Result getOverTime(@RequestParam("uid") int uid,@RequestParam("rtype")String rtype){
        return recordService.getOverTime(uid,rtype);
    }
}
